import 'dart:convert' show json;

import 'package:flutter_common_app/data/protection.dart';

class AccountData {
  AccountData({
    this.id,
    this.userName,
    this.type,
    this.status,
    this.whitelistAuthority,
    this.createTime,
    this.tokenVersion,
    this.ban,
    this.baoyueVersion,
    this.donateVersion,
    this.vipType,
    this.anonimousUser,
    this.paidFee,
  });

  factory AccountData.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : AccountData(
    id: asT<int>(jsonRes['id']),
    userName: asT<String>(jsonRes['userName']),
    type: asT<int>(jsonRes['type']),
    status: asT<int>(jsonRes['status']),
    whitelistAuthority: asT<int>(jsonRes['whitelistAuthority']),
    createTime: asT<int>(jsonRes['createTime']),
    tokenVersion: asT<int>(jsonRes['tokenVersion']),
    ban: asT<int>(jsonRes['ban']),
    baoyueVersion: asT<int>(jsonRes['baoyueVersion']),
    donateVersion: asT<int>(jsonRes['donateVersion']),
    vipType: asT<int>(jsonRes['vipType']),
    anonimousUser: asT<bool>(jsonRes['anonimousUser']),
    paidFee: asT<bool>(jsonRes['paidFee']),
  );

  int id;
  String userName;
  int type;
  int status;
  int whitelistAuthority;
  int createTime;
  int tokenVersion;
  int ban;
  int baoyueVersion;
  int donateVersion;
  int vipType;
  bool anonimousUser;
  bool paidFee;

  Map<String, dynamic> toJson() => <String, dynamic>{
    'id': id,
    'userName': userName,
    'type': type,
    'status': status,
    'whitelistAuthority': whitelistAuthority,
    'createTime': createTime,
    'tokenVersion': tokenVersion,
    'ban': ban,
    'baoyueVersion': baoyueVersion,
    'donateVersion': donateVersion,
    'vipType': vipType,
    'anonimousUser': anonimousUser,
    'paidFee': paidFee,
  };
  @override
  String toString() {
    return json.encode(this);
  }
}
